<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>添加学生</title>
    <link rel="stylesheet" th:replace="base::styles"/>
</head>
<body>
<div th:replace="base::nav-bar"></div>

<div class="container">


    <div class="row">

        <div class="col-lg-4"></div>
        <div class="col-lg-4">
            <form action="/person/" method="post">

                <input type="hidden" name="_method" value="put" th:if="${person!=null}"/>
                <input type="hidden" name="id" th:value="${person.id}" th:if="${person!=null}"/>
                <input type="hidden" name="avatar" th:value="${person.avatar}" th:if="${person!=null}"/>

                <div class="form-group">
                    <label>姓名</label>
                    <input type="text" name="name" class="form-control" placeholder="姓名"
                           th:value="${person!=null}?${person.name}"/>
                </div>
                <div class="form-group">
                    <label>年龄</label>
                    <input type="text" name="age" class="form-control" placeholder="年龄"
                           th:value="${person!=null}?${person.age}"/>
                </div>
                <div class="form-group">
                    <label>籍贯</label>
                    <select name="address" class="form-control">
                        <option th:each="addr:${addrs}" th:value="${addr.id}" th:text="${addr.name}"
                                th:selected="${person!=null}?${addr.name==person.address.name}"/>
                    </select>
                </div>
                <button type="submit" class="btn btn-success">提交</button>

            </form>

            <p th:text="${msg}" th:if="not ${#strings.isEmpty(msg)}"></p>

        </div>
        <div class="col-lg-4"></div>

    </div>


</div>


<div th:replace="base::scripts"></div>
</body>
</html>